package cn.wolfcode.p2p.business.service.impl;

import cn.wolfcode.p2p.business.domain.BidRequest;
import cn.wolfcode.p2p.business.domain.BidRequestAuditHistory;
import cn.wolfcode.p2p.business.mapper.BidRequestAuditHistoryMapper;
import cn.wolfcode.p2p.business.service.IBidRequestAuditHistoryService;
import cn.wolfcode.p2p.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;

@Service
@Transactional
public class BidRequestAuditHistoryServiceImpl implements IBidRequestAuditHistoryService {

    @Autowired
    private BidRequestAuditHistoryMapper historyMapper;

    @Override
    public void save(BidRequest br, String remark, Integer state, int auditType) {
        //保存设置用户信息
        BidRequestAuditHistory auditHistory = new BidRequestAuditHistory();
        auditHistory.setBidRequestId(br.getId());
        auditHistory.setState(state);
        auditHistory.setRemark(remark);
        auditHistory.setAuditor(UserContext.getLoginInfo());
        auditHistory.setAuditType(auditType);
        auditHistory.setApplier(br.getCreateUser());
        auditHistory.setApplyTime(br.getApplyTime());
        auditHistory.setAuditTime(new Date());
        historyMapper.insert(auditHistory);
    }

}
